package com._54programer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com._54programer.ws.CacheKey;
import com._54programer.ws.Const;
import com.hazelcast.core.HazelcastInstance;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/server")
@Slf4j
public class ServerInfoController {

	@Autowired
	private HazelcastInstance Hi;

	@Autowired
	private CacheKey Ck;

	@GetMapping("/info")
	public Object Server() throws InterruptedException {
		log.info("HazelcastInstance info :{}", Hi.getConfig());

		
		for (int i = 0; i < 500; i++) {
			Ck.putMul("name", "zhz3");
			Ck.putSet("test", "obj1", Hi.getSet(Const.SERVER_INFO));
			Ck.putSet("test", "obj2", Hi.getSet(Const.SERVER_INFO));
			Ck.putSet("test", "obj3", Hi.getSet(Const.SERVER_INFO));
		}

		//关闭当前缓存节点
		Hi.shutdown();
		
//		log.info("{}",Hi.getCacheManager().toString());
//		log.info("{}",Hi.getConfig().getCacheConfigs());
//		return Hi.getSet(Const.SERVER_INFO);
		return "shutdown HazelcastInstance success!";
//		return Ck.getMul("name");
//		return Ck.getSet("test");

	}
}
